package com.geticsen.leetcode;

public class Solution_112 {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root != null && root.right == null && root.left == null) {
            return targetSum == 0;
        }
        if (targetSum < 0) {
            return false;
        }
        if (root == null) return false;
        return hasPathSum(root.left, targetSum - root.val) ||
                hasPathSum(root.right, targetSum - root.val);
    }
}
